package CacheLayer;

import Helpers.ApplicationLogger;

class CacheFactory<T extends AbstractCache> {
	private T cache;
	
	public T getCacheInstance(Class<T> clazz)
	{
		ApplicationLogger.getInstance().LOG.debug("Creating cache: " + clazz.getName());
		if(cache == null)
		{
			try {
				cache = clazz.newInstance();
			} catch (InstantiationException e) {
				ApplicationLogger.getInstance().LOG.error(e.getMessage());
			} catch (IllegalAccessException e) {
				ApplicationLogger.getInstance().LOG.error(e.getMessage());
				e.printStackTrace();
			}
		}
		return cache;
	}
}
